]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
hwtest.js: Don't parse JSON with regexps
authorOwen W. Taylor <otaylor@fishsoup.net>
Wed, 16 Jul 2014 17:20:15 +0000 (13:20 -0400)
committerOwen W. Taylor <otaylor@fishsoup.net>
Wed, 16 Jul 2014 17:22:13 +0000 (13:22 -0400)
Use JSON.parse() to parse systemd log records, rather than using
regexps.

https://bugzilla.gnome.org/show_bug.cgi?id=732350

js/perf/hwtest.js

index 1f0b18193730713e55ef95163d140ad6222ce8b1..8ef61025d00bc757cd4858797fb65c8234e55ab6 100644 (file)
@@ -78,7 +78,7 @@ function extractBootTimestamp() {
                                  'MESSAGE_ID=7d4958e842da4a758f6c1cdc7b36dcc5',
                                  'UNIT=graphical.target',
                                  '-o',
-                                 'json-pretty'],
+                                 'json'],
                                 Gio.SubprocessFlags.STDOUT_PIPE);
     let result = null;
 
@@ -88,10 +88,8 @@ function extractBootTimestamp() {
         if (line === null)
             break;
 
-        let m = /.*"__MONOTONIC_TIMESTAMP".*"([0-9]+)"/.exec(line);
-        if (m) {
-            result = Number(m[1]);
-        }
+        let fields = JSON.parse(line);
+        result = Number(fields['__MONOTONIC_TIMESTAMP']);
     }
     datastream.close(null);
     return result;